<?php

declare(strict_types=1);

namespace Zyucv7\Components\AI\LLM;

// 客户端的工厂类
class ClientFactory
{

    private static $clients = [];

    public static function create($name, array $options = [])
    {
        if(!isset(self::$clients[$name])) {
            $clientName = '\\Zyucv7\\Components\\AI\\LLM\\ClientType\\' . ucfirst($name);
            self::$clients[$name] = new $clientName();
            if(isset($options['model'])) {
                // 修改模型名称
                self::$clients[$name]->setModel($options['model']);
            }
        } else {
            throw new \Exception("Client $name not found");
        }

        return self::$clients[$name];
    }
}
